package com.ruoyi.psi.inventory.record.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.psi.inventory.record.domain.PurchaseOrderStockInRecord;
import com.ruoyi.psi.inventory.record.domain.StockInRecord;
import com.ruoyi.psi.inventory.record.domain.StockInRecordCond;
import com.ruoyi.psi.inventory.record.service.IStockInRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 入库记录
 * 控制层接口
 */
@RestController
@RequestMapping("/psi/stock/in/record")
@Api(value = "入库记录模块", tags = "入库记录接口")
public class StockInRecordController extends BaseController {
    @Autowired
    private IStockInRecordService stockInRecordService;

    /**
     * 获取入库记录
     * @param cond
     * @return
     */
    @ApiOperation(value = "获取入库记录列表",notes = "查询所有入库记录")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody StockInRecordCond cond) {
        startPage();
        List<StockInRecord> selectStockInRecordList = stockInRecordService.selectStockInRecordList(cond);
        return getDataTable(selectStockInRecordList);
    }

    /**
     * 导出入库记录
     *
     * @param cond
     * @return
     */
    @PostMapping("/export")
    public AjaxResult export(@RequestBody StockInRecordCond cond) {
        List<StockInRecord> selectStockInRecordList = stockInRecordService.selectStockInRecordList(cond);
        ExcelUtil<StockInRecord> util = new ExcelUtil<>(StockInRecord.class);
        return util.exportExcel(selectStockInRecordList, "入库记录数据");
    }

    /**
     * 获取采购订单入库记录
     * @param cond
     * @return
     */
    @ApiOperation(value = "获取采购订单入库记录",notes = "获取采购订单入库记录")
    @PostMapping("/selectPurchaseOrderStockInRecordList")
    public TableDataInfo selectPurchaseOrderStockInRecordList(@RequestBody StockInRecordCond cond) {
        startPage();
        List<PurchaseOrderStockInRecord> purchaseOrderStockInRecords = stockInRecordService.selectPurchaseOrderStockInRecordList(cond);
        return getDataTable(purchaseOrderStockInRecords);
    }
}
